package com.example.user1.util;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class PasswordEncoderUtil {

    private static PasswordEncoder passwordEncoder;

    public PasswordEncoderUtil(PasswordEncoderFactory passwordEncoderFactory) {
        this.passwordEncoder = passwordEncoderFactory.get();
    }

    public static String encoder(String password) {
        return passwordEncoder.encode(password);
    }

    public static boolean match(String password, String old) {
        return passwordEncoder.matches(password, old);
    }
}
